<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>附件信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
        var multipartMaxSize = '${multipartMaxSize}';
    </script>
</head>
<body>

<form class="layui-form" action="" style="padding: 10px 75px;">
    <div class="layui-upload-drag" type="file" name="xmlFile" id="xmlFile">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
    </div>
    <div class="layui-btn-container layui-footer" style="position: absolute;left:37%;bottom:0">
        <button type="button" class="layui-btn layui-btn-sm" id="importButton">上传</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger" id="return">取消</button>
    </div>
</form>
<div hidden id="selectFile">
    <input type="hidden" name="fileId">
    <input type="hidden" name="fileName">
</div>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','element', 'upload', 'jquery','commons'], function () {
        var element = layui.element;
        var upload = layui.upload;
        var $ = layui.$;
        var setter = layui.setter;
        var layer = layui.layer;
        var commons = layui.commons;

        var index = parent.layer.getFrameIndex(window.name);
        $('#return').click(function () {
            parent.layer.close(index);
        })
        //指定允许上传的文件类型
        upload.render({
            elem: '#xmlFile'
            , url: serverPath.systemPath + setter.sysLinkPath +'attachFile/fileUpload'
            , accept: 'file'
            ,size: multipartMaxSize
            , multiple: true
            , auto: false //选择文件后不自动上传
            , bindAction: '#importButton' //指向一个按钮触发上传
            // , data:{typeId:'${typeId}'}
            , before: function () {
            }
            , done: function (res) {
                if (res.code == 1) {
                    layer.alert(res.msg);
                } else {
                    layer.alert(res.msg, function () {
                        var data=res.data.fileList[0];
                        parent.$("#attachment").val(data.fileId);
                        parent.$('#selectedFileName').text(data.fileName+"."+data.extName);
                        parent.$('#attachmentSpan').removeAttr('hidden');
                        commons.bulletWindow(index);
                    });
                }
            }
        });
    })
</script>
</body>
</html>